{{ $color := "primary" }}
{{ $latest_version := .Site.Params.url_latest_version }}
{{ $path := strings.TrimPrefix (add hugo.WorkingDir "/content/en/") $.File.Filename -}}

{{ if strings.HasPrefix $path "latest" }}
<div class="alert alert-warning">
    Notice:
    <br />
    This is the "latest" release of Envoy Gateway, which contains the most recent commits from the main branch.
    <br />
    This release <strong>might not be stable</strong>.
    <br />
    Please refer to the <a href="{{ $latest_version | safeURL }}" target="_blank">/docs</a> documentation for the most current information.
</div>
{{ end }}

{{ range .Site.Params.versions -}}

{{ $eol_time := time.AsTime .eol }}
{{ if gt (time.Now.Sub $eol_time) 0 }}

{{ if strings.HasPrefix $path .version }}
<div class="alert alert-warning">
    Notice: You're viewing documentation for an older version of Envoy Gateway that has reached End of Life (EOL).
    <br />
    Please refer to the <a href="{{ $latest_version | safeURL }}" target="_blank">/docs</a> documentation for the most current information.
</div>
{{ end }}

{{ end }}

{{ end }}
